﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="../js/jquery.min.js"></script>
    <script src="../js/jquery.easyui.min.js"></script>
    <script src="../js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="../themes/icon.css">
    <link rel="stylesheet" href="../themes/default/easyui.css">
    <link rel="stylesheet" href="../css/wu.css">
    <script>
        var  selectIndex = -1;
        function hideTable(){
            $("#searchdiv").toggle();
        }
 		$(function(){
            $("#productList").datagrid({
                /* fit:true, */
                url:'/kxmanage/power/showrole',
             /*    rownumbers:true, */
                pageNumber:1,
                pageSize:5,
                pageList:[5,10,20,30],
                pagination:true,
                showFooter:true,
                columns:[[
                    {field:'ck',checkbox:true},
                    {field:'id',title:'角色代码',width:150,formatter:function(value,row,index){
                    	return '<a onclick="showrole(\''+value+'\')" style="color:blue;text-decoration:underline" href="#">'+value+'</a>'
                    }},
                    {field:'roleName',title:'角色名称',width:150},
                   	{field:'opt',title:'操作',width:180,formatter:function (value,row,index) {
                            var context="<a href=\"javascript:delrole('"+row.id+"')\">删除</a>&nbsp;&nbsp;" +
                                "<a href=\"javascript:modifyrole('"+row.id+"')\">编辑</a>&nbsp;&nbsp;"+
                                "<a href=\"javascript:power('"+row.id+"')\">设置权限</a>&nbsp;&nbsp;" 
                            return context;
                        }}
                ]],
                toolbar:'#wu_toolbar',
                //不选中行
                onClickRow:function(index,data){
                	$(this).datagrid('unselectRow',index);
                }
            });
            
			$("#search_btn").click(function(){
				var form=$("#form1");
				$("#productList").datagrid('load',serializeForm(form));
			});
			
        });
		//将表单序列化        
		function serializeForm(form){
			var obj={};
			$.each(form.serializeArray(),function(index){
				  if(obj[this['name']]){
					obj[this['name']]=obj[this['name']]+','+this['value']
				 }else{
				   obj[this['name']]=this['value'];
				 }
			});
			return obj;
		}
        function showrole(id){
        	parent.addTabs("角色管理","/kxmanage/power/findone?id="+id);
        }
        function addpart() {
            parent.addTabs("角色管理","goods/addRole.jsp");
        }
        function modifyrole(id) {
            parent.addTabs("角色管理","/kxmanage/power/modifyone?id="+id);
        }
        function power(id){
        	parent.addTabs("权限","/kxmanage/power/turn?id="+id);
        }
        //单行删除
        function delrole(id){
           $.messager.confirm('确认','您确认想要删除记录吗？',function(r){
           if (r==true){
	             $.ajax({
	      			type:"post",//请求类型
	      			url:"/kxmanage/power/delete?id="+id, 
	      			dataType:"json",//ajax接口（请求url）返回的数据类型
	      			success:function(data){//data：返回数据（json对象）
	         			if(data.result=="success"){
	              			$.messager.alert('消息'," 删除成功！");
	                    			$('#productList').datagrid('reload');//删除后重新加载下
	         			}else if(data.result=="error"){
	              			$.messager.alert('消息'," 删除失败！");
	         			}
	      			}
	     		 });
		      }		
           	});
           }
        
        function reload(){
        	location.reload();
        }
        
        function reset(){
        	$("#form1").form('reset');
        }
    </script>

</head>
<body>
<div id="wu_toolbar">
    <div class="wu_toolbar_button">
        <a  href="#" onclick="hideTable()" class="easyui-linkbutton" data-options="iconCls:'icon-search'" plain="true">查询</a>|
        <a  href="#" onclick="addpart()" class="easyui-linkbutton" data-options="iconCls:'icon-add'" plain="true">添加</a>|
        <a  href="#" onclick="reload()" class="easyui-linkbutton" data-options="iconCls:'icon-page-refresh'" plain="true">刷新</a>|
        <a  href="#" onclick="reload()" class="easyui-linkbutton" data-options="iconCls:'icon-communication'" plain="true">导出excal</a>
    </div>
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1" action="/kxmanage/osb/show" method="post">
		<input name="page" value="1" type="hidden"/>
		<input name="rows" value="5" type="hidden"/>
            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
                <tbody><tr>
                    <td width="70"><b>检索条件:</b></td>
                    <td width="70" align="right">类别编号:</td>
                    <td width="150" align="left"><input name="rid" class="easyui-textbox" type="text" id="findcode" value="" maxlength="100"></td>
                    <td width="70" align="right">所属类别:</td>
                    <td width="150" align="left"><input name="roleName" class="easyui-textbox" type="text" id="findcode" value="" maxlength="100"></td>
                    <td width="72">
                        <a id="search_btn" href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn" href="#" onclick="reset()" class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>


                </tr>
                </tbody>
            </table>
            <input type="hidden" id="rid" value="">
        </form>
    </div>
</div>
<div id="productList" class="easyui-datagrid">

</div>

</body>
</html>